\(\int \tanh (c+d x) (a+b \tanh ^2(c+d x))^2 \, dx\) [147]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 57 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=\frac {(a+b)^2 \log (\cosh (c+d x))}{d}-\frac {b (a+b) \tanh ^2(c+d x)}{2 d}-\frac {\left (a+b \tanh ^2(c+d x)\right )^2}{4 d} \]

[Out]

(a+b)^2*ln(cosh(d*x+c))/d-1/2*b*(a+b)*tanh(d*x+c)^2/d-1/4*(a+b*tanh(d*x+c)^2)^2/d

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 57, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3751, 455, 45} \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=-\frac {b (a+b) \tanh ^2(c+d x)}{2 d}-\frac {\left (a+b \tanh ^2(c+d x)\right )^2}{4 d}+\frac {(a+b)^2 \log (\cosh (c+d x))}{d} \]

[In]

Int[Tanh[c + d*x]*(a + b*Tanh[c + d*x]^2)^2,x]

[Out]

((a + b)^2*Log[Cosh[c + d*x]])/d - (b*(a + b)*Tanh[c + d*x]^2)/(2*d) - (a + b*Tanh[c + d*x]^2)^2/(4*d)

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 455

Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Dist[1/n, Subst[Int
[(a + b*x)^p*(c + d*x)^q, x], x, x^n], x] /; FreeQ[{a, b, c, d, m, n, p, q}, x] && NeQ[b*c - a*d, 0] && EqQ[m
- n + 1, 0]

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {x \left (a+b x^2\right )^2}{1-x^2} \, dx,x,\tanh (c+d x)\right )}{d} \\ & = \frac {\text {Subst}\left (\int \frac {(a+b x)^2}{1-x} \, dx,x,\tanh ^2(c+d x)\right )}{2 d} \\ & = \frac {\text {Subst}\left (\int \left (-b (a+b)+\frac {(a+b)^2}{1-x}-b (a+b x)\right ) \, dx,x,\tanh ^2(c+d x)\right )}{2 d} \\ & = \frac {(a+b)^2 \log (\cosh (c+d x))}{d}-\frac {b (a+b) \tanh ^2(c+d x)}{2 d}-\frac {\left (a+b \tanh ^2(c+d x)\right )^2}{4 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.37 (sec) , antiderivative size = 50, normalized size of antiderivative = 0.88 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=-\frac {-4 (a+b)^2 \log (\cosh (c+d x))+2 b (2 a+b) \tanh ^2(c+d x)+b^2 \tanh ^4(c+d x)}{4 d} \]

[In]

Integrate[Tanh[c + d*x]*(a + b*Tanh[c + d*x]^2)^2,x]

[Out]

-1/4*(-4*(a + b)^2*Log[Cosh[c + d*x]] + 2*b*(2*a + b)*Tanh[c + d*x]^2 + b^2*Tanh[c + d*x]^4)/d

Maple [A] (verified)

Time = 0.10 (sec) , antiderivative size = 92, normalized size of antiderivative = 1.61

method result size
derivativedivides \(\frac {-\frac {\tanh \left (d x +c \right )^{4} b^{2}}{4}-\tanh \left (d x +c \right )^{2} a b -\frac {b^{2} \tanh \left (d x +c \right )^{2}}{2}-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (\tanh \left (d x +c \right )-1\right )}{2}+\frac {\left (-a^{2}-2 a b -b^{2}\right ) \ln \left (\tanh \left (d x +c \right )+1\right )}{2}}{d}\) \(92\)
default \(\frac {-\frac {\tanh \left (d x +c \right )^{4} b^{2}}{4}-\tanh \left (d x +c \right )^{2} a b -\frac {b^{2} \tanh \left (d x +c \right )^{2}}{2}-\frac {\left (a^{2}+2 a b +b^{2}\right ) \ln \left (\tanh \left (d x +c \right )-1\right )}{2}+\frac {\left (-a^{2}-2 a b -b^{2}\right ) \ln \left (\tanh \left (d x +c \right )+1\right )}{2}}{d}\) \(92\)
parts \(\frac {a^{2} \ln \left (\cosh \left (d x +c \right )\right )}{d}+\frac {b^{2} \left (-\frac {\tanh \left (d x +c \right )^{4}}{4}-\frac {\tanh \left (d x +c \right )^{2}}{2}-\frac {\ln \left (\tanh \left (d x +c \right )-1\right )}{2}-\frac {\ln \left (\tanh \left (d x +c \right )+1\right )}{2}\right )}{d}+\frac {2 a b \left (-\frac {\tanh \left (d x +c \right )^{2}}{2}-\frac {\ln \left (\tanh \left (d x +c \right )-1\right )}{2}-\frac {\ln \left (\tanh \left (d x +c \right )+1\right )}{2}\right )}{d}\) \(106\)
parallelrisch \(-\frac {\tanh \left (d x +c \right )^{4} b^{2}+4 a^{2} d x +8 a b d x +4 b^{2} d x +4 \tanh \left (d x +c \right )^{2} a b +2 b^{2} \tanh \left (d x +c \right )^{2}+4 \ln \left (1-\tanh \left (d x +c \right )\right ) a^{2}+8 \ln \left (1-\tanh \left (d x +c \right )\right ) a b +4 \ln \left (1-\tanh \left (d x +c \right )\right ) b^{2}}{4 d}\) \(111\)
risch \(-a^{2} x -2 a b x -b^{2} x -\frac {2 a^{2} c}{d}-\frac {4 a b c}{d}-\frac {2 c \,b^{2}}{d}+\frac {4 b \,{\mathrm e}^{2 d x +2 c} \left (a \,{\mathrm e}^{4 d x +4 c}+b \,{\mathrm e}^{4 d x +4 c}+2 \,{\mathrm e}^{2 d x +2 c} a +b \,{\mathrm e}^{2 d x +2 c}+a +b \right )}{d \left ({\mathrm e}^{2 d x +2 c}+1\right )^{4}}+\frac {a^{2} \ln \left ({\mathrm e}^{2 d x +2 c}+1\right )}{d}+\frac {2 a b \ln \left ({\mathrm e}^{2 d x +2 c}+1\right )}{d}+\frac {\ln \left ({\mathrm e}^{2 d x +2 c}+1\right ) b^{2}}{d}\) \(178\)

[In]

int(tanh(d*x+c)*(a+b*tanh(d*x+c)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(-1/4*tanh(d*x+c)^4*b^2-tanh(d*x+c)^2*a*b-1/2*b^2*tanh(d*x+c)^2-1/2*(a^2+2*a*b+b^2)*ln(tanh(d*x+c)-1)+1/2*
(-a^2-2*a*b-b^2)*ln(tanh(d*x+c)+1))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1638 vs. \(2 (53) = 106\).

Time = 0.28 (sec) , antiderivative size = 1638, normalized size of antiderivative = 28.74 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=\text {Too large to display} \]

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2)^2,x, algorithm="fricas")

[Out]

-((a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)^8 + 8*(a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)*sinh(d*x + c)^7 + (a^2 + 2
*a*b + b^2)*d*x*sinh(d*x + c)^8 + 4*((a^2 + 2*a*b + b^2)*d*x - a*b - b^2)*cosh(d*x + c)^6 + 4*(7*(a^2 + 2*a*b
+ b^2)*d*x*cosh(d*x + c)^2 + (a^2 + 2*a*b + b^2)*d*x - a*b - b^2)*sinh(d*x + c)^6 + 8*(7*(a^2 + 2*a*b + b^2)*d
*x*cosh(d*x + c)^3 + 3*((a^2 + 2*a*b + b^2)*d*x - a*b - b^2)*cosh(d*x + c))*sinh(d*x + c)^5 + 2*(3*(a^2 + 2*a*
b + b^2)*d*x - 4*a*b - 2*b^2)*cosh(d*x + c)^4 + 2*(35*(a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)^4 + 3*(a^2 + 2*a*b
 + b^2)*d*x + 30*((a^2 + 2*a*b + b^2)*d*x - a*b - b^2)*cosh(d*x + c)^2 - 4*a*b - 2*b^2)*sinh(d*x + c)^4 + 8*(7
*(a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)^5 + 10*((a^2 + 2*a*b + b^2)*d*x - a*b - b^2)*cosh(d*x + c)^3 + (3*(a^2
+ 2*a*b + b^2)*d*x - 4*a*b - 2*b^2)*cosh(d*x + c))*sinh(d*x + c)^3 + (a^2 + 2*a*b + b^2)*d*x + 4*((a^2 + 2*a*b
 + b^2)*d*x - a*b - b^2)*cosh(d*x + c)^2 + 4*(7*(a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)^6 + 15*((a^2 + 2*a*b + b
^2)*d*x - a*b - b^2)*cosh(d*x + c)^4 + (a^2 + 2*a*b + b^2)*d*x + 3*(3*(a^2 + 2*a*b + b^2)*d*x - 4*a*b - 2*b^2)
*cosh(d*x + c)^2 - a*b - b^2)*sinh(d*x + c)^2 - ((a^2 + 2*a*b + b^2)*cosh(d*x + c)^8 + 8*(a^2 + 2*a*b + b^2)*c
osh(d*x + c)*sinh(d*x + c)^7 + (a^2 + 2*a*b + b^2)*sinh(d*x + c)^8 + 4*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^6 + 4
*(7*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^2 + a^2 + 2*a*b + b^2)*sinh(d*x + c)^6 + 8*(7*(a^2 + 2*a*b + b^2)*cosh(d
*x + c)^3 + 3*(a^2 + 2*a*b + b^2)*cosh(d*x + c))*sinh(d*x + c)^5 + 6*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^4 + 2*(
35*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^4 + 30*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^2 + 3*a^2 + 6*a*b + 3*b^2)*sinh(
d*x + c)^4 + 8*(7*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^5 + 10*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^3 + 3*(a^2 + 2*a*
b + b^2)*cosh(d*x + c))*sinh(d*x + c)^3 + 4*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^2 + 4*(7*(a^2 + 2*a*b + b^2)*cos
h(d*x + c)^6 + 15*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^4 + 9*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^2 + a^2 + 2*a*b +
b^2)*sinh(d*x + c)^2 + a^2 + 2*a*b + b^2 + 8*((a^2 + 2*a*b + b^2)*cosh(d*x + c)^7 + 3*(a^2 + 2*a*b + b^2)*cosh
(d*x + c)^5 + 3*(a^2 + 2*a*b + b^2)*cosh(d*x + c)^3 + (a^2 + 2*a*b + b^2)*cosh(d*x + c))*sinh(d*x + c))*log(2*
cosh(d*x + c)/(cosh(d*x + c) - sinh(d*x + c))) + 8*((a^2 + 2*a*b + b^2)*d*x*cosh(d*x + c)^7 + 3*((a^2 + 2*a*b
+ b^2)*d*x - a*b - b^2)*cosh(d*x + c)^5 + (3*(a^2 + 2*a*b + b^2)*d*x - 4*a*b - 2*b^2)*cosh(d*x + c)^3 + ((a^2
+ 2*a*b + b^2)*d*x - a*b - b^2)*cosh(d*x + c))*sinh(d*x + c))/(d*cosh(d*x + c)^8 + 8*d*cosh(d*x + c)*sinh(d*x
+ c)^7 + d*sinh(d*x + c)^8 + 4*d*cosh(d*x + c)^6 + 4*(7*d*cosh(d*x + c)^2 + d)*sinh(d*x + c)^6 + 8*(7*d*cosh(d
*x + c)^3 + 3*d*cosh(d*x + c))*sinh(d*x + c)^5 + 6*d*cosh(d*x + c)^4 + 2*(35*d*cosh(d*x + c)^4 + 30*d*cosh(d*x
 + c)^2 + 3*d)*sinh(d*x + c)^4 + 8*(7*d*cosh(d*x + c)^5 + 10*d*cosh(d*x + c)^3 + 3*d*cosh(d*x + c))*sinh(d*x +
 c)^3 + 4*d*cosh(d*x + c)^2 + 4*(7*d*cosh(d*x + c)^6 + 15*d*cosh(d*x + c)^4 + 9*d*cosh(d*x + c)^2 + d)*sinh(d*
x + c)^2 + 8*(d*cosh(d*x + c)^7 + 3*d*cosh(d*x + c)^5 + 3*d*cosh(d*x + c)^3 + d*cosh(d*x + c))*sinh(d*x + c) +
 d)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 122 vs. \(2 (48) = 96\).

Time = 0.13 (sec) , antiderivative size = 122, normalized size of antiderivative = 2.14 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=\begin {cases} a^{2} x - \frac {a^{2} \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} + 2 a b x - \frac {2 a b \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} - \frac {a b \tanh ^{2}{\left (c + d x \right )}}{d} + b^{2} x - \frac {b^{2} \log {\left (\tanh {\left (c + d x \right )} + 1 \right )}}{d} - \frac {b^{2} \tanh ^{4}{\left (c + d x \right )}}{4 d} - \frac {b^{2} \tanh ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tanh ^{2}{\left (c \right )}\right )^{2} \tanh {\left (c \right )} & \text {otherwise} \end {cases} \]

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)**2)**2,x)

[Out]

Piecewise((a**2*x - a**2*log(tanh(c + d*x) + 1)/d + 2*a*b*x - 2*a*b*log(tanh(c + d*x) + 1)/d - a*b*tanh(c + d*
x)**2/d + b**2*x - b**2*log(tanh(c + d*x) + 1)/d - b**2*tanh(c + d*x)**4/(4*d) - b**2*tanh(c + d*x)**2/(2*d),
Ne(d, 0)), (x*(a + b*tanh(c)**2)**2*tanh(c), True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 186 vs. \(2 (53) = 106\).

Time = 0.28 (sec) , antiderivative size = 186, normalized size of antiderivative = 3.26 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=b^{2} {\left (x + \frac {c}{d} + \frac {\log \left (e^{\left (-2 \, d x - 2 \, c\right )} + 1\right )}{d} + \frac {4 \, {\left (e^{\left (-2 \, d x - 2 \, c\right )} + e^{\left (-4 \, d x - 4 \, c\right )} + e^{\left (-6 \, d x - 6 \, c\right )}\right )}}{d {\left (4 \, e^{\left (-2 \, d x - 2 \, c\right )} + 6 \, e^{\left (-4 \, d x - 4 \, c\right )} + 4 \, e^{\left (-6 \, d x - 6 \, c\right )} + e^{\left (-8 \, d x - 8 \, c\right )} + 1\right )}}\right )} + 2 \, a b {\left (x + \frac {c}{d} + \frac {\log \left (e^{\left (-2 \, d x - 2 \, c\right )} + 1\right )}{d} + \frac {2 \, e^{\left (-2 \, d x - 2 \, c\right )}}{d {\left (2 \, e^{\left (-2 \, d x - 2 \, c\right )} + e^{\left (-4 \, d x - 4 \, c\right )} + 1\right )}}\right )} + \frac {a^{2} \log \left (\cosh \left (d x + c\right )\right )}{d} \]

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2)^2,x, algorithm="maxima")

[Out]

b^2*(x + c/d + log(e^(-2*d*x - 2*c) + 1)/d + 4*(e^(-2*d*x - 2*c) + e^(-4*d*x - 4*c) + e^(-6*d*x - 6*c))/(d*(4*
e^(-2*d*x - 2*c) + 6*e^(-4*d*x - 4*c) + 4*e^(-6*d*x - 6*c) + e^(-8*d*x - 8*c) + 1))) + 2*a*b*(x + c/d + log(e^
(-2*d*x - 2*c) + 1)/d + 2*e^(-2*d*x - 2*c)/(d*(2*e^(-2*d*x - 2*c) + e^(-4*d*x - 4*c) + 1))) + a^2*log(cosh(d*x
 + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 116 vs. \(2 (53) = 106\).

Time = 0.33 (sec) , antiderivative size = 116, normalized size of antiderivative = 2.04 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=-\frac {{\left (a^{2} + 2 \, a b + b^{2}\right )} {\left (d x + c\right )} - {\left (a^{2} + 2 \, a b + b^{2}\right )} \log \left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right ) - \frac {4 \, {\left ({\left (a b + b^{2}\right )} e^{\left (6 \, d x + 6 \, c\right )} + {\left (2 \, a b + b^{2}\right )} e^{\left (4 \, d x + 4 \, c\right )} + {\left (a b + b^{2}\right )} e^{\left (2 \, d x + 2 \, c\right )}\right )}}{{\left (e^{\left (2 \, d x + 2 \, c\right )} + 1\right )}^{4}}}{d} \]

[In]

integrate(tanh(d*x+c)*(a+b*tanh(d*x+c)^2)^2,x, algorithm="giac")

[Out]

-((a^2 + 2*a*b + b^2)*(d*x + c) - (a^2 + 2*a*b + b^2)*log(e^(2*d*x + 2*c) + 1) - 4*((a*b + b^2)*e^(6*d*x + 6*c
) + (2*a*b + b^2)*e^(4*d*x + 4*c) + (a*b + b^2)*e^(2*d*x + 2*c))/(e^(2*d*x + 2*c) + 1)^4)/d

Mupad [B] (verification not implemented)

Time = 1.83 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.33 \[ \int \tanh (c+d x) \left (a+b \tanh ^2(c+d x)\right )^2 \, dx=x\,\left (a^2+2\,a\,b+b^2\right )-\frac {{\mathrm {tanh}\left (c+d\,x\right )}^2\,\left (b^2+2\,a\,b\right )}{2\,d}-\frac {\ln \left (\mathrm {tanh}\left (c+d\,x\right )+1\right )\,\left (a^2+2\,a\,b+b^2\right )}{d}-\frac {b^2\,{\mathrm {tanh}\left (c+d\,x\right )}^4}{4\,d} \]

[In]

int(tanh(c + d*x)*(a + b*tanh(c + d*x)^2)^2,x)

[Out]

x*(2*a*b + a^2 + b^2) - (tanh(c + d*x)^2*(2*a*b + b^2))/(2*d) - (log(tanh(c + d*x) + 1)*(2*a*b + a^2 + b^2))/d
 - (b^2*tanh(c + d*x)^4)/(4*d)